

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="深海火锅店">
  <meta name="keywords" content="">
  
    <meta name="description" content="全新Activiti7工作流讲解一、Activiti7概述官网地址：https:&#x2F;&#x2F;www.activiti.org&#x2F; &amp;emsp;&amp;emsp;Activiti由Alfresco软件开发，目前最高版本Activiti 7。是BPMN的一个基于java的软件实现，不过Activiti 不仅仅包括BPMN，还有DMN决策表和CMMN Case管理引擎，并且有自己的用户管理、微服务API">
<meta property="og:type" content="article">
<meta property="og:title" content="Activiti7">
<meta property="og:url" content="http://example.com/2024/03/01/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E5%AD%A6%E4%B9%A0/%E6%A1%86%E6%9E%B6/Activiti/Activiti7/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="全新Activiti7工作流讲解一、Activiti7概述官网地址：https:&#x2F;&#x2F;www.activiti.org&#x2F; &amp;emsp;&amp;emsp;Activiti由Alfresco软件开发，目前最高版本Activiti 7。是BPMN的一个基于java的软件实现，不过Activiti 不仅仅包括BPMN，还有DMN决策表和CMMN Case管理引擎，并且有自己的用户管理、微服务API">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245900.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245006.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245918.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245332.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245982.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245884.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245820.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245125.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245689.png">
<meta property="og:image" content="c:\Users\dpb\AppData\Roaming\Typora\typora-user-images\image-20230519112027397.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245281.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246185.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246862.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246137.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246104.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246614.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246605.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246908.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246049.png">
<meta property="article:published_time" content="2024-03-01T10:00:00.000Z">
<meta property="article:modified_time" content="2024-03-03T12:44:55.276Z">
<meta property="article:author" content="深海火锅店">
<meta property="article:tag" content="Activiti7">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245900.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>Activiti7 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fluid</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/background.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="Activiti7"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-03-01 18:00" pubdate>
          2024年3月1日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          17k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          140 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Activiti7</h1>
            
            
              <div class="markdown-body">
                
                <h1 id="全新Activiti7工作流讲解"><a href="#全新Activiti7工作流讲解" class="headerlink" title="全新Activiti7工作流讲解"></a>全新Activiti7工作流讲解</h1><h1 id="一、Activiti7概述"><a href="#一、Activiti7概述" class="headerlink" title="一、Activiti7概述"></a>一、Activiti7概述</h1><p>官网地址：<a target="_blank" rel="noopener" href="https://www.activiti.org/">https://www.activiti.org/</a></p>
<p>&amp;emsp;&amp;emsp;Activiti由Alfresco软件开发，目前最高版本Activiti 7。是BPMN的一个基于java的软件实现，不过Activiti 不仅仅包括BPMN，还有DMN决策表和CMMN Case管理引擎，并且有自己的用户管理、微服务API等一系列功能，是一个服务平台。</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245900.png" srcset="/img/loading.gif" lazyload alt="image-20230517195056636"></p>
<h1 id="二、Activiti7的入门案例"><a href="#二、Activiti7的入门案例" class="headerlink" title="二、Activiti7的入门案例"></a>二、Activiti7的入门案例</h1><p>官方手册：<a target="_blank" rel="noopener" href="http://jeecg.com/activiti5.21/">http://jeecg.com/activiti5.21/</a></p>
<h2 id="1-创建SpringBoot项目"><a href="#1-创建SpringBoot项目" class="headerlink" title="1.创建SpringBoot项目"></a>1.创建SpringBoot项目</h2><p>&amp;emsp;&amp;emsp;现在开发中或者我们自己学习写案例都是通过SpringBoot脚手架工具来快速构建项目的。那么我们也就直接通过创建SpringBoot项目来给大家讲解相关的案例。创建一个普通的SpringBoot项目。指定版本为2.4.2即可</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245006.png" srcset="/img/loading.gif" lazyload alt="image-20230517211943193"></p>
<p>&amp;emsp;&amp;emsp;然后添加对应的依赖：Activiti7的依赖和MySQL的依赖</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">properties</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">java.version</span>&gt;</span>1.8<span class="hljs-tag">&lt;/<span class="hljs-name">java.version</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">project.build.sourceEncoding</span>&gt;</span>UTF-8<span class="hljs-tag">&lt;/<span class="hljs-name">project.build.sourceEncoding</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">project.reporting.outputEncoding</span>&gt;</span>UTF-8<span class="hljs-tag">&lt;/<span class="hljs-name">project.reporting.outputEncoding</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">spring-boot.version</span>&gt;</span>2.4.2<span class="hljs-tag">&lt;/<span class="hljs-name">spring-boot.version</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">properties</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">dependencies</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>mysql<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>mysql-connector-java<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>8.0.23<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-starter-test<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>test<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.activiti<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>activiti-spring-boot-starter<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>7.0.0.GA<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">dependencies</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">dependencyManagement</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">dependencies</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-dependencies<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>$&#123;spring-boot.version&#125;<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">type</span>&gt;</span>pom<span class="hljs-tag">&lt;/<span class="hljs-name">type</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">scope</span>&gt;</span>import<span class="hljs-tag">&lt;/<span class="hljs-name">scope</span>&gt;</span><br>            <span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">dependencies</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">dependencyManagement</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">build</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">plugins</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">plugin</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.maven.plugins<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>maven-compiler-plugin<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.8.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-name">source</span>&gt;</span>1.8<span class="hljs-tag">&lt;/<span class="hljs-name">source</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-name">target</span>&gt;</span>1.8<span class="hljs-tag">&lt;/<span class="hljs-name">target</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-name">encoding</span>&gt;</span>UTF-8<span class="hljs-tag">&lt;/<span class="hljs-name">encoding</span>&gt;</span><br>                <span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span><br>            <span class="hljs-tag">&lt;/<span class="hljs-name">plugin</span>&gt;</span><br>            <span class="hljs-tag">&lt;<span class="hljs-name">plugin</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.springframework.boot<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>spring-boot-maven-plugin<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>$&#123;spring-boot.version&#125;<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">configuration</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-name">mainClass</span>&gt;</span>com.boge.act.PrepareDemo2Application<span class="hljs-tag">&lt;/<span class="hljs-name">mainClass</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-name">skip</span>&gt;</span>true<span class="hljs-tag">&lt;/<span class="hljs-name">skip</span>&gt;</span><br>                <span class="hljs-tag">&lt;/<span class="hljs-name">configuration</span>&gt;</span><br>                <span class="hljs-tag">&lt;<span class="hljs-name">executions</span>&gt;</span><br>                    <span class="hljs-tag">&lt;<span class="hljs-name">execution</span>&gt;</span><br>                        <span class="hljs-tag">&lt;<span class="hljs-name">id</span>&gt;</span>repackage<span class="hljs-tag">&lt;/<span class="hljs-name">id</span>&gt;</span><br>                        <span class="hljs-tag">&lt;<span class="hljs-name">goals</span>&gt;</span><br>                            <span class="hljs-tag">&lt;<span class="hljs-name">goal</span>&gt;</span>repackage<span class="hljs-tag">&lt;/<span class="hljs-name">goal</span>&gt;</span><br>                        <span class="hljs-tag">&lt;/<span class="hljs-name">goals</span>&gt;</span><br>                    <span class="hljs-tag">&lt;/<span class="hljs-name">execution</span>&gt;</span><br>                <span class="hljs-tag">&lt;/<span class="hljs-name">executions</span>&gt;</span><br>            <span class="hljs-tag">&lt;/<span class="hljs-name">plugin</span>&gt;</span><br>        <span class="hljs-tag">&lt;/<span class="hljs-name">plugins</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">build</span>&gt;</span><br><br></code></pre></td></tr></table></figure>

<p>相关的Activiti依赖加载进来了</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245918.png" srcset="/img/loading.gif" lazyload alt="image-20230517212124728"></p>
<p>到这儿基本环境就OK了</p>
<h2 id="2-获取ProcessEngine"><a href="#2-获取ProcessEngine" class="headerlink" title="2.获取ProcessEngine"></a>2.获取ProcessEngine</h2><h3 id="2-1-默认的方式"><a href="#2-1-默认的方式" class="headerlink" title="2.1 默认的方式"></a>2.1 默认的方式</h3><p>&amp;emsp;&amp;emsp;在工作流引擎框架中，<code>ProcessEngine</code>是一个非常核心的对象，我们需要首先解决这个对象的获取。获取方式很多。先来看最简单的一个基于<code>activiti.cfg.xml</code>的XML文件的配置方式。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-meta">@Test</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test1</span><span class="hljs-params">()</span>&#123;<br>    <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">processEngine</span> <span class="hljs-operator">=</span> ProcessEngines.getDefaultProcessEngine();<br>    System.out.println(processEngine);<br>&#125;<br></code></pre></td></tr></table></figure>

<p>&amp;emsp;&amp;emsp;通过<code>getDefaultProcessEngine</code>方法加载会默认的从classpath路径下加载<code>activiti.cfg.xml</code>配置文件。我们添加该文件。内容如下：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">beans</span> <span class="hljs-attr">xmlns</span>=<span class="hljs-string">&quot;http://www.springframework.org/schema/beans&quot;</span></span><br><span class="hljs-tag">       <span class="hljs-attr">xmlns:xsi</span>=<span class="hljs-string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span><br><span class="hljs-tag">       <span class="hljs-attr">xsi:schemaLocation</span>=<span class="hljs-string">&quot;http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd&quot;</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">bean</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;processEngineConfiguration&quot;</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration&quot;</span>&gt;</span><br><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcUrl&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;jdbc:mysql://localhost:3306/activiti7&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcDriver&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;com.mysql.cj.jdbc.Driver&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcUsername&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;root&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcPassword&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;123456&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;databaseSchemaUpdate&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;true&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;asyncExecutorActivate&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;false&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;mailServerHost&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;mail.my-corp.com&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;mailServerPort&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;5025&quot;</span> /&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">bean</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">beans</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>然后我们就可以启动，但是出现了如下错误：</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245332.png" srcset="/img/loading.gif" lazyload alt="image-20230517211345644"></p>
<p>&amp;emsp;&amp;emsp;出现这种情况只需要在mysql的连接字符串中添加上nullCatalogMeansCurrent&#x3D;true，设置为只查当前连接的schema库即可。</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">beans</span> <span class="hljs-attr">xmlns</span>=<span class="hljs-string">&quot;http://www.springframework.org/schema/beans&quot;</span></span><br><span class="hljs-tag">       <span class="hljs-attr">xmlns:xsi</span>=<span class="hljs-string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span><br><span class="hljs-tag">       <span class="hljs-attr">xsi:schemaLocation</span>=<span class="hljs-string">&quot;http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd&quot;</span>&gt;</span><br><br>    <span class="hljs-tag">&lt;<span class="hljs-name">bean</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;processEngineConfiguration&quot;</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration&quot;</span>&gt;</span><br><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcUrl&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;jdbc:mysql://localhost:3306/activiti7?nullCatalogMeansCurrent=true&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcDriver&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;com.mysql.cj.jdbc.Driver&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcUsername&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;root&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;jdbcPassword&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;123456&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;databaseSchemaUpdate&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;true&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;asyncExecutorActivate&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;false&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;mailServerHost&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;mail.my-corp.com&quot;</span> /&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">property</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;mailServerPort&quot;</span> <span class="hljs-attr">value</span>=<span class="hljs-string">&quot;5025&quot;</span> /&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">bean</span>&gt;</span><br><br><span class="hljs-tag">&lt;/<span class="hljs-name">beans</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>然后执行程序正确。搞定。同时在数据库中创建了相关的表结构</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245982.png" srcset="/img/loading.gif" lazyload alt="image-20230517212912548"></p>
<h3 id="2-2-编程方式获取"><a href="#2-2-编程方式获取" class="headerlink" title="2.2 编程方式获取"></a>2.2 编程方式获取</h3><p>&amp;emsp;&amp;emsp;上面的配置文件的方式中的配置文件其实是一个Spring的配置文件，但是这并不意味着Activiti只能用于Spring环境。我们也可以通过编程的方式来使用配置文件，从而来构建ProcessEngineConfiguration对象，具体的实现如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-meta">@Test</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test2</span><span class="hljs-params">()</span>&#123;<br>    <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">engine</span> <span class="hljs-operator">=</span> ProcessEngineConfiguration<br>        	.createStandaloneInMemProcessEngineConfiguration()<br>            .setJdbcUrl(<span class="hljs-string">&quot;jdbc:mysql://localhost:3306/activiti7?nullCatalogMeansCurrent=true&quot;</span>)<br>            .setJdbcDriver(<span class="hljs-string">&quot;com.mysql.cj.jdbc.Driver&quot;</span>)<br>            .setJdbcPassword(<span class="hljs-string">&quot;123456&quot;</span>)<br>            .setJdbcUsername(<span class="hljs-string">&quot;root&quot;</span>)<br>            .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)<br>            .buildProcessEngine();<br>    System.out.println(engine);<br>&#125;<br></code></pre></td></tr></table></figure>

<p>上面讲解中的相关属性说明：</p>
<p><strong>databaseSchemaUpdate</strong>：用于设置流程引擎启动关闭时使用的数据库表结构控制策略</p>
<ul>
<li><code>false</code> (默认): 当引擎启动时，检查数据库表结构的版本是否匹配库文件版本。版本不匹配时抛出异常。</li>
<li><code>true</code>: 构建引擎时，检查并在需要时更新表结构。表结构不存在则会创建。</li>
<li><code>create-drop</code>: 引擎创建时创建表结构，并在引擎关闭时删除表结构。</li>
</ul>
<h3 id="2-3-表结构介绍"><a href="#2-3-表结构介绍" class="headerlink" title="2.3 表结构介绍"></a>2.3 表结构介绍</h3><p>&amp;emsp;&amp;emsp;在Activiti7中。我们启动服务会自动维护Activiti7需要使用到的相关的表结构。在这块我们需要有个大概的了解。首先是支持的数据库有：</p>
<table>
<thead>
<tr>
<th>Activiti数据库类型</th>
<th>示例JDBC URL</th>
<th>备注</th>
</tr>
</thead>
<tbody><tr>
<td>h2</td>
<td>jdbc:h2:tcp:&#x2F;&#x2F;localhost&#x2F;activiti</td>
<td>默认配置的数据库</td>
</tr>
<tr>
<td>mysql</td>
<td>jdbc:mysql:&#x2F;&#x2F;localhost:3306&#x2F;activiti?autoReconnect&#x3D;true</td>
<td>已使用mysql-connector-java数据库驱动测试</td>
</tr>
<tr>
<td>oracle</td>
<td>jdbc:oracle:thin:@localhost:1521:xe</td>
<td></td>
</tr>
<tr>
<td>postgres</td>
<td>jdbc:postgresql:&#x2F;&#x2F;localhost:5432&#x2F;activiti</td>
<td></td>
</tr>
<tr>
<td>db2</td>
<td>jdbc:db2:&#x2F;&#x2F;localhost:50000&#x2F;activiti</td>
<td></td>
</tr>
<tr>
<td>mssql</td>
<td>jdbc:sqlserver:&#x2F;&#x2F;localhost:1433;databaseName&#x3D;activiti (jdbc.driver&#x3D;com.microsoft.sqlserver.jdbc.SQLServerDriver) <em>OR</em> jdbc:jtds:sqlserver:&#x2F;&#x2F;localhost:1433&#x2F;activiti (jdbc.driver&#x3D;net.sourceforge.jtds.jdbc.Driver)</td>
<td>已使用Microsoft JDBC Driver 4.0 (sqljdb</td>
</tr>
</tbody></table>
<p>&amp;emsp;&amp;emsp;Activiti的所有数据库表都以**ACT_**开头。第二部分是说明表用途的两字符标示符。服务API的命名也大略符合这个规则。</p>
<p><strong>ACT_RE_</strong>*: <code>RE</code>代表<code>repository</code>。带有这个前缀的表包含“静态”信息，例如流程定义与流程资源（图片、规则等）。</p>
<p><strong>ACT_RU_</strong>*: <code>RU</code>代表<code>runtime</code>。这些表存储运行时信息，例如流程实例（process instance）、用户任务（user task）、变量（variable）、作业（job）等。Activiti只在流程实例运行中保存运行时数据，并在流程实例结束时删除记录。这样保证运行时表小和快。</p>
<p><strong>ACT_ID_</strong>*: <code>ID</code>代表<code>identity</code>。这些表包含身份信息，例如用户、组等。</p>
<p><strong>ACT_HI_</strong>*: <code>HI</code>代表<code>history</code>。这些表存储历史数据，例如已完成的流程实例、变量、任务等。</p>
<p><strong>ACT_GE_</strong>*: 通用数据。用于不同场景下</p>
<p>注意：MySQL数据库最好使用5.7及以上的版本</p>
<h2 id="3-在线流程设计器"><a href="#3-在线流程设计器" class="headerlink" title="3.在线流程设计器"></a>3.在线流程设计器</h2><p>&amp;emsp;&amp;emsp;接下来我们通过官方提供的流程设计器来实现一个简单流程的设计。然后完成相关的部署和流程整体操作。</p>
<p>官网下载地址：<a target="_blank" rel="noopener" href="https://www.activiti.org/get-started">https://www.activiti.org/get-started</a> 下载下来后解压缩</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245884.png" srcset="/img/loading.gif" lazyload alt="image-20230519111655829"></p>
<p>进入到wars中。提供的有Activiti-app.war</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245820.png" srcset="/img/loading.gif" lazyload alt="image-20230519111731391"></p>
<p>把这war包拷贝到Tomcat服务器中即可。注意Tomcat的版本不要高于8.5，然后Tomcat服务。访问 <a target="_blank" rel="noopener" href="http://localhost:8080/activiti-app">http://localhost:8080/activiti-app</a> 即可。登录的账号密码是 admin  test</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245125.png" srcset="/img/loading.gif" lazyload alt="image-20230519111931446"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245689.png" srcset="/img/loading.gif" lazyload alt="image-20230519112000632"></p>
<p><img src="C:\Users\dpb\AppData\Roaming\Typora\typora-user-images\image-20230519112027397.png" srcset="/img/loading.gif" lazyload alt="image-20230519112027397"></p>
<p>点击create process 弹出窗口。录入相关的流程定义信息</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242245281.png" srcset="/img/loading.gif" lazyload alt="image-20230519112212684"></p>
<p>绘制好流程图后。保存并下载对应的xml文件</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246185.png" srcset="/img/loading.gif" lazyload alt="image-20230519112253385"></p>
<p>得到的流程图的xml内容：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-meta">&lt;?xml version=<span class="hljs-string">&quot;1.0&quot;</span> encoding=<span class="hljs-string">&quot;UTF-8&quot;</span>?&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">definitions</span> <span class="hljs-attr">xmlns</span>=<span class="hljs-string">&quot;http://www.omg.org/spec/BPMN/20100524/MODEL&quot;</span> <span class="hljs-attr">xmlns:xsi</span>=<span class="hljs-string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span class="hljs-attr">xmlns:xsd</span>=<span class="hljs-string">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span class="hljs-attr">xmlns:activiti</span>=<span class="hljs-string">&quot;http://activiti.org/bpmn&quot;</span> <span class="hljs-attr">xmlns:bpmndi</span>=<span class="hljs-string">&quot;http://www.omg.org/spec/BPMN/20100524/DI&quot;</span> <span class="hljs-attr">xmlns:omgdc</span>=<span class="hljs-string">&quot;http://www.omg.org/spec/DD/20100524/DC&quot;</span> <span class="hljs-attr">xmlns:omgdi</span>=<span class="hljs-string">&quot;http://www.omg.org/spec/DD/20100524/DI&quot;</span> <span class="hljs-attr">typeLanguage</span>=<span class="hljs-string">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> <span class="hljs-attr">expressionLanguage</span>=<span class="hljs-string">&quot;http://www.w3.org/1999/XPath&quot;</span> <span class="hljs-attr">targetNamespace</span>=<span class="hljs-string">&quot;http://www.activiti.org/processdef&quot;</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">process</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;test1&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;test1&quot;</span> <span class="hljs-attr">isExecutable</span>=<span class="hljs-string">&quot;true&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">documentation</span>&gt;</span>test1<span class="hljs-tag">&lt;/<span class="hljs-name">documentation</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">startEvent</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;startEvent1&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">startEvent</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">userTask</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;sid-470631FF-51BA-4954-96BB-346B99CA0A2C&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;人事审批&quot;</span> <span class="hljs-attr">activiti:assignee</span>=<span class="hljs-string">&quot;zhangsan&quot;</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">extensionElements</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">modeler:initiator-can-complete</span> <span class="hljs-attr">xmlns:modeler</span>=<span class="hljs-string">&quot;http://activiti.com/modeler&quot;</span>&gt;</span>&lt;![CDATA[false]]&gt;<span class="hljs-tag">&lt;/<span class="hljs-name">modeler:initiator-can-complete</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">extensionElements</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">userTask</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">sequenceFlow</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;sid-B53369E8-E698-4F53-AE40-97E7654BFA78&quot;</span> <span class="hljs-attr">sourceRef</span>=<span class="hljs-string">&quot;startEvent1&quot;</span> <span class="hljs-attr">targetRef</span>=<span class="hljs-string">&quot;sid-470631FF-51BA-4954-96BB-346B99CA0A2C&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">sequenceFlow</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">userTask</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;sid-34454522-B109-41C9-8519-59D29B621099&quot;</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;经理审批&quot;</span> <span class="hljs-attr">activiti:assignee</span>=<span class="hljs-string">&quot;lisi&quot;</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">extensionElements</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">modeler:initiator-can-complete</span> <span class="hljs-attr">xmlns:modeler</span>=<span class="hljs-string">&quot;http://activiti.com/modeler&quot;</span>&gt;</span>&lt;![CDATA[false]]&gt;<span class="hljs-tag">&lt;/<span class="hljs-name">modeler:initiator-can-complete</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">extensionElements</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">userTask</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">sequenceFlow</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;sid-5AE88ADE-9FD3-48F2-81EF-528DA0C068CB&quot;</span> <span class="hljs-attr">sourceRef</span>=<span class="hljs-string">&quot;sid-470631FF-51BA-4954-96BB-346B99CA0A2C&quot;</span> <span class="hljs-attr">targetRef</span>=<span class="hljs-string">&quot;sid-34454522-B109-41C9-8519-59D29B621099&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">sequenceFlow</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">endEvent</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;sid-EA0332FA-59B0-45C0-9D24-47C78051D52C&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">endEvent</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">sequenceFlow</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;sid-F6C0657A-C92F-4DEA-AAB1-93750FFBD7E5&quot;</span> <span class="hljs-attr">sourceRef</span>=<span class="hljs-string">&quot;sid-34454522-B109-41C9-8519-59D29B621099&quot;</span> <span class="hljs-attr">targetRef</span>=<span class="hljs-string">&quot;sid-EA0332FA-59B0-45C0-9D24-47C78051D52C&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">sequenceFlow</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">process</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNDiagram</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNDiagram_test1&quot;</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNPlane</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;test1&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNPlane_test1&quot;</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNShape</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;startEvent1&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNShape_startEvent1&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdc:Bounds</span> <span class="hljs-attr">height</span>=<span class="hljs-string">&quot;30.0&quot;</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;30.0&quot;</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;100.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;163.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdc:Bounds</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNShape</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNShape</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;sid-470631FF-51BA-4954-96BB-346B99CA0A2C&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNShape_sid-470631FF-51BA-4954-96BB-346B99CA0A2C&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdc:Bounds</span> <span class="hljs-attr">height</span>=<span class="hljs-string">&quot;80.0&quot;</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;100.0&quot;</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;175.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;138.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdc:Bounds</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNShape</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNShape</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;sid-34454522-B109-41C9-8519-59D29B621099&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNShape_sid-34454522-B109-41C9-8519-59D29B621099&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdc:Bounds</span> <span class="hljs-attr">height</span>=<span class="hljs-string">&quot;80.0&quot;</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;100.0&quot;</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;320.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;138.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdc:Bounds</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNShape</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNShape</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;sid-EA0332FA-59B0-45C0-9D24-47C78051D52C&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNShape_sid-EA0332FA-59B0-45C0-9D24-47C78051D52C&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdc:Bounds</span> <span class="hljs-attr">height</span>=<span class="hljs-string">&quot;28.0&quot;</span> <span class="hljs-attr">width</span>=<span class="hljs-string">&quot;28.0&quot;</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;465.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;164.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdc:Bounds</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNShape</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNEdge</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;sid-5AE88ADE-9FD3-48F2-81EF-528DA0C068CB&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNEdge_sid-5AE88ADE-9FD3-48F2-81EF-528DA0C068CB&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdi:waypoint</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;275.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;178.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdi:waypoint</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdi:waypoint</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;320.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;178.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdi:waypoint</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNEdge</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNEdge</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;sid-F6C0657A-C92F-4DEA-AAB1-93750FFBD7E5&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNEdge_sid-F6C0657A-C92F-4DEA-AAB1-93750FFBD7E5&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdi:waypoint</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;420.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;178.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdi:waypoint</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdi:waypoint</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;465.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;178.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdi:waypoint</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNEdge</span>&gt;</span><br>      <span class="hljs-tag">&lt;<span class="hljs-name">bpmndi:BPMNEdge</span> <span class="hljs-attr">bpmnElement</span>=<span class="hljs-string">&quot;sid-B53369E8-E698-4F53-AE40-97E7654BFA78&quot;</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;BPMNEdge_sid-B53369E8-E698-4F53-AE40-97E7654BFA78&quot;</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdi:waypoint</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;130.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;178.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdi:waypoint</span>&gt;</span><br>        <span class="hljs-tag">&lt;<span class="hljs-name">omgdi:waypoint</span> <span class="hljs-attr">x</span>=<span class="hljs-string">&quot;175.0&quot;</span> <span class="hljs-attr">y</span>=<span class="hljs-string">&quot;178.0&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">omgdi:waypoint</span>&gt;</span><br>      <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNEdge</span>&gt;</span><br>    <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNPlane</span>&gt;</span><br>  <span class="hljs-tag">&lt;/<span class="hljs-name">bpmndi:BPMNDiagram</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">definitions</span>&gt;</span><br></code></pre></td></tr></table></figure>

<p>然后我们就可以做流程的部署操作了</p>
<h2 id="4-流程操作"><a href="#4-流程操作" class="headerlink" title="4.流程操作"></a>4.流程操作</h2><h3 id="4-1-流程部署"><a href="#4-1-流程部署" class="headerlink" title="4.1 流程部署"></a>4.1 流程部署</h3><p>&amp;emsp;&amp;emsp;设计好了流程图我们就可以通过如下的代码完成流程的部署。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment">  * 流程部署操作</span><br><span class="hljs-comment">  */</span><br> <span class="hljs-meta">@Test</span><br> <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test3</span><span class="hljs-params">()</span>&#123;<br>     <span class="hljs-comment">// 1.获取ProcessEngine对象</span><br>     <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">processEngine</span> <span class="hljs-operator">=</span> ProcessEngines.getDefaultProcessEngine();<br>     <span class="hljs-comment">// 2.完成流程的部署操作 需要通过RepositoryService来完成</span><br>     <span class="hljs-type">RepositoryService</span> <span class="hljs-variable">repositoryService</span> <span class="hljs-operator">=</span> processEngine.getRepositoryService();<br>     <span class="hljs-comment">// 3.完成部署操作</span><br>     <span class="hljs-type">Deployment</span> <span class="hljs-variable">deploy</span> <span class="hljs-operator">=</span> repositoryService.createDeployment()<br>             .addClasspathResource(<span class="hljs-string">&quot;flow/test1.bpmn20.xml&quot;</span>)<br>             .name(<span class="hljs-string">&quot;第一个流程&quot;</span>)<br>             .deploy();<br>     System.out.println(deploy.getId());<br>     System.out.println(deploy.getName());<br> &#125;<br></code></pre></td></tr></table></figure>

<p>流程部署的行为会涉及到数据库中的这两张表</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246862.png" srcset="/img/loading.gif" lazyload alt="image-20230519114622514"></p>
<p>然后我们可以通过Activiti提供的相关的API来获取流程部署和流程定义的相关信息</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 查询当前部署的流程有哪些</span><br><span class="hljs-comment"> */</span><br><span class="hljs-meta">@Test</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test4</span><span class="hljs-params">()</span>&#123;<br>    <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">engine</span> <span class="hljs-operator">=</span> ProcessEngines.getDefaultProcessEngine();<br>    <span class="hljs-type">RepositoryService</span> <span class="hljs-variable">repositoryService</span> <span class="hljs-operator">=</span> engine.getRepositoryService();<br>    <span class="hljs-comment">// 查询有哪些部署的流程--》查询相关的流程定义信息</span><br>    <span class="hljs-comment">// repositoryService.createDeploymentQuery() 查询流程部署的相关信息</span><br>    <span class="hljs-comment">// repositoryService.createProcessDefinitionQuery() 查询部署的流程的相关的定义</span><br>    List&lt;Deployment&gt; list = repositoryService.createDeploymentQuery().list(); <span class="hljs-comment">// 查询所有的部署信息</span><br>    <span class="hljs-keyword">for</span> (Deployment deployment : list) &#123;<br>        System.out.println(deployment.getId());<br>        System.out.println(deployment.getName());<br>    &#125;<br><br>    List&lt;ProcessDefinition&gt; list1 = repositoryService.createProcessDefinitionQuery().list();<br>    <span class="hljs-keyword">for</span> (ProcessDefinition processDefinition : list1) &#123;<br>        System.out.println(processDefinition.getId());<br>        System.out.println(processDefinition.getName());<br>        System.out.println(processDefinition.getDescription());<br>    &#125;<br><br>&#125;<br></code></pre></td></tr></table></figure>

<h3 id="4-2-发起流程"><a href="#4-2-发起流程" class="headerlink" title="4.2 发起流程"></a>4.2 发起流程</h3><p>&amp;emsp;&amp;emsp;部署流程成功后。我们就可以发起一个流程。发起流程需要通过<code>RuntimeService</code>来实现。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 发起一个流程</span><br><span class="hljs-comment"> */</span><br><span class="hljs-meta">@Test</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test5</span><span class="hljs-params">()</span>&#123;<br>    <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">engine</span> <span class="hljs-operator">=</span> ProcessEngines.getDefaultProcessEngine();<br>    <span class="hljs-comment">// 发起流程 需要通过 runtimeService来实现</span><br>    <span class="hljs-type">RuntimeService</span> <span class="hljs-variable">runtimeService</span> <span class="hljs-operator">=</span> engine.getRuntimeService();<br>    <span class="hljs-comment">// 通过流程定义ID来启动流程  返回的是流程实例对象</span><br>    <span class="hljs-type">ProcessInstance</span> <span class="hljs-variable">processInstance</span> <span class="hljs-operator">=</span> runtimeService<br>            .startProcessInstanceById(<span class="hljs-string">&quot;test1:1:3&quot;</span>);<br>    System.out.println(<span class="hljs-string">&quot;processInstance.getId() = &quot;</span> + processInstance.getId());<br>    System.out.println(<span class="hljs-string">&quot;processInstance.getDeploymentId() = &quot;</span> + processInstance.getDeploymentId());<br>    System.out.println(<span class="hljs-string">&quot;processInstance.getDescription() = &quot;</span> + processInstance.getDescription());<br>&#125;<br></code></pre></td></tr></table></figure>

<p>发起流程成功后。在对应的<code>act_ru_task</code>中就有一条对应的待办记录。</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246137.png" srcset="/img/loading.gif" lazyload alt="image-20230520100457878"></p>
<p>对应的流程状态如下：</p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246104.png" srcset="/img/loading.gif" lazyload alt="image-20230520100513859"></p>
<h3 id="4-3-查询流程"><a href="#4-3-查询流程" class="headerlink" title="4.3 查询流程"></a>4.3 查询流程</h3><p>&amp;emsp;&amp;emsp;用户登录后要查看待办的任务信息。我们需要通过<code>TaskService</code>来实现查询操作。具体代码如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment">     * 待办查询</span><br><span class="hljs-comment">     */</span><br>    <span class="hljs-meta">@Test</span><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test6</span><span class="hljs-params">()</span>&#123;<br>        <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">engine</span> <span class="hljs-operator">=</span> ProcessEngines.getDefaultProcessEngine();<br>        <span class="hljs-comment">// 待办查询 执行中的任务处理通过 TaskService来实现</span><br>        <span class="hljs-type">TaskService</span> <span class="hljs-variable">taskService</span> <span class="hljs-operator">=</span> engine.getTaskService();<br>        <span class="hljs-comment">// Task 对象对应的其实就是 act_ru_task 这张表的记录</span><br>        List&lt;Task&gt; list = taskService.createTaskQuery().taskAssignee(<span class="hljs-string">&quot;lisi&quot;</span>).list();<br>        <span class="hljs-keyword">if</span>(list != <span class="hljs-literal">null</span> &amp;&amp; list.size() &gt; <span class="hljs-number">0</span>)&#123;<br>            <span class="hljs-keyword">for</span> (Task task : list) &#123;<br>                System.out.println(task.getId());<br>                System.out.println(task.getName());<br>                System.out.println(task.getAssignee());<br>            &#125;<br>        &#125;<span class="hljs-keyword">else</span>&#123;<br>            System.out.println(<span class="hljs-string">&quot;当前没有待办任务&quot;</span>);<br>        &#125;<br>    &#125;<br></code></pre></td></tr></table></figure>





<h3 id="4-4-审批流程"><a href="#4-4-审批流程" class="headerlink" title="4.4 审批流程"></a>4.4 审批流程</h3><p>&amp;emsp;&amp;emsp;当前登录用户查看到相关的待办信息后。可以做流程的审批处理。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">/**</span><br><span class="hljs-comment"> * 任务审批</span><br><span class="hljs-comment"> */</span><br><span class="hljs-meta">@Test</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">test7</span><span class="hljs-params">()</span>&#123;<br>    <span class="hljs-type">ProcessEngine</span> <span class="hljs-variable">engine</span> <span class="hljs-operator">=</span> ProcessEngines.getDefaultProcessEngine();<br>    <span class="hljs-comment">// 做任务申请 也需要通过 TaskService 来实现</span><br>    <span class="hljs-type">TaskService</span> <span class="hljs-variable">taskService</span> <span class="hljs-operator">=</span> engine.getTaskService();<br>    <span class="hljs-comment">// 根据当前登录用户查询出对应的待办信息</span><br>    List&lt;Task&gt; list = taskService.createTaskQuery().taskAssignee(<span class="hljs-string">&quot;lisi&quot;</span>).list();<br>    <span class="hljs-keyword">if</span>(list != <span class="hljs-literal">null</span> &amp;&amp; list.size() &gt; <span class="hljs-number">0</span>)&#123;<br>        <span class="hljs-keyword">for</span> (Task task : list) &#123;<br>            <span class="hljs-comment">// 做对应的任务审批处理</span><br>            taskService.complete(task.getId());<br>        &#125;<br>    &#125;<br>    <span class="hljs-comment">// 完成任务</span><br>    <span class="hljs-comment">// taskService.complete(&quot;2505&quot;);</span><br>&#125;<br></code></pre></td></tr></table></figure>



<h2 id="5-涉及表结构"><a href="#5-涉及表结构" class="headerlink" title="5.涉及表结构"></a>5.涉及表结构</h2><p>&amp;emsp;&amp;emsp;上面一个审批涉及到的表结构的介绍</p>
<table>
<thead>
<tr>
<th>表名</th>
<th>说明</th>
</tr>
</thead>
<tbody><tr>
<td>act_re_deployment</td>
<td>部署流程的记录表：一次部署行为会产生一张表</td>
</tr>
<tr>
<td>act_re_procdef</td>
<td>流程定义表：一张流程图对应的表</td>
</tr>
<tr>
<td>act_hi_procinst</td>
<td>流程实例表：发起一个流程。就会创建对应的一张表</td>
</tr>
<tr>
<td>act_ru_task</td>
<td>流程待办表：当前需要审批的记录表，节点审批后就会被删除</td>
</tr>
<tr>
<td>act_hi_actinst</td>
<td>历史记录：流程审批节点的记录信息</td>
</tr>
</tbody></table>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246614.png" srcset="/img/loading.gif" lazyload alt="相关表结构"></p>
<h1 id="三、表达式"><a href="#三、表达式" class="headerlink" title="三、表达式"></a>三、表达式</h1><h2 id="值表达式"><a href="#值表达式" class="headerlink" title="值表达式"></a>值表达式</h2><p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246605.png" srcset="/img/loading.gif" lazyload alt="image-20230623091854461"></p>
<blockquote>
<p><code>$&#123;&#125;</code></p>
</blockquote>
<h2 id="方法表达式"><a href="#方法表达式" class="headerlink" title="方法表达式"></a>方法表达式</h2><p>方法表达式Method expression:调用一个方法， 可以带或不带参数。当调不带参数的方法时，要确保在方法名后添加空括号(以避免与值表达式混淆)。传递的参数可以是字面值,也可以是表达式，它们会被自动解析。例如:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><code class="hljs java">$&#123;printer.print()&#125;<br>$&#123;myBean.getAssignee()&#125;<br>$&#123;myBean.addNewOrder(<span class="hljs-string">&#x27;orderName&#x27;</span>)&#125;<br>$&#123;myBean.doSomething(myVar,execution)&#125;<br></code></pre></td></tr></table></figure>

<h2 id="监听器"><a href="#监听器" class="headerlink" title="监听器"></a>监听器</h2><p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246908.png" srcset="/img/loading.gif" lazyload alt="image-20230623132637416"></p>
<p><img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202306242246049.png" srcset="/img/loading.gif" lazyload alt="image-20230623132659870"></p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/Activiti7/" class="category-chain-item">Activiti7</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/Activiti7/">#Activiti7</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>Activiti7</div>
      <div>http://example.com/2024/03/01/编程语言/Java/学习/框架/Activiti/Activiti7/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>深海火锅店</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年3月1日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2024/03/01/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E5%AD%A6%E4%B9%A0/%E6%A1%86%E6%9E%B6/Mockito/Mockito/" title="Mockito">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Mockito</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2024/03/01/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E5%AD%A6%E4%B9%A0/%E6%A1%86%E6%9E%B6/Docker/Docker/" title="Docker">
                        <span class="hidden-mobile">Docker</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="//cdn.jsdelivr.net/gh/EmoryHuang/BlogBeautify@1.1/DynamicRibbon.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
